magento 2 block called as child pass product variable

92

protected $product;

public function setProduct($_product){
    $this->product = $_product;
}

public function getProduct(){
    return $this->product;
}
<?php echo $block->getProduct()->getId(); ?>
<?php /* Start Custom Changes */ ?>
<?php if ($myBlock = $block->getChildBlock('my_child_block')): ?>
    <?php
        $myBlock->setProduct($_product); 
        echo $block->getChildHtml('my_child_block', false);
    ?>
<?php endif; ?>
<?php /* End Custom Changes */ ?>

Comments

Submit
0 Comments